package com.yanghui.dtracing.common.util;

import java.io.Serializable;

public class Result<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private Integer code;
    private String desc;

    private boolean i18n = true;
    private ResultData<T> result;

    public Result() {
    }

    public Result(Integer code, String msg) {
        this.code = code;
        this.desc = msg;
    }

    public Integer getCode() {
        return this.code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return this.desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public boolean isI18n() {
        return this.i18n;
    }

    public void setI18n(boolean i18n) {
        this.i18n = i18n;
    }

    public T getResultData() {
        return this.result.getData();
    }

    public ResultData<T> getResult() {
        return this.result;
    }

    public void setResult(ResultData<T> result) {
        if (result.getEncrypt() == null) {
            result.setEncrypt(EncryptFlag.NONE.name());
        }

        this.result = result;
    }

    public boolean isSuccess() {
        return this.code != null && this.code == 0;
    }
}
